<?php
/**
 * Describe:前台会员类 包括注册的邮箱短信验证 忘记密码等
 * Source:
 * User: blue
 * Time: 2018/3/26 21:19
 */

namespace ocean;


class UserLogin
{

    /**
     *发送用户注册验证,来自TP3.2需要重写
     */
    public function sendCode($id){
        $where['id']=$id;
//        生成一个唯一的随机数
        $data['email_code']=md5(uniqid());
//       把随机数写入数据库
        $this->where($where)->setField($data);
        $url="http://localhost/oschina/Addons_Project/Addons/index.php/user/regist/emailCheck/uid/".$where['id'].'/ecode/'.$data['email_code'];
        $title="简繁中国用户注册验证";
        $toeamil=$data['user_email'];
        $content="欢迎您注册简繁中国请点击<a herf=$url target='_blank'>激活用户</a>,如果链接失效,请手动访问{$url}地址进行激活";
        return sendMail($toeamil,$title,$content);
    }
    /**
     * 用户注册邮箱验证,来自tp3.2,需要重写
     */
    public function emailCheck()
    {
        $where['id'] = input('param.uid');
        $ecode = input('param.ecode');
        $data = $this->_model->lists($where);
        if ($ecode == $data[0]['email_code']) {
            $change['email_check'] = 1;
            $change['email_code'] = '';
            $res = $this->_model->where($where)->setField($change);
            if ($res) {
                $this->success('用户激活成功', 'User/User/index');
            } else {
                $this->error('用户激活失败' . $this->_model->getError());
            }
        }
    }
    /*
     * 找回密码
     */
    public function findPWD(){

    }
}